#TARGET_TYPE = ZYNQ7020
TARGET_TYPE = ZYNQMP
MODULE_NAME = s_qspi_drv

ifeq ($(TARGET_TYPE), ZYNQMP)
KERN_DIR = /disk2/kernel-src-zynqMQ
ARCH := arm64
CROSS_COMPILE := aarch64-linux-gnu-
MODULE_FINAL_NAME = s_qspi_drv_mp
else
KERN_DIR = /disk2/zynq_linux_src_2018
ARCH := arm
CROSS_COMPILE := arm-linux-gnueabihf-
MODULE_FINAL_NAME = s_qspi_drv_z7
endif

#EXTRA_CFLAGS += -Werror

TARGET_DIR := /home/felix/nfs_dir/
 
.PHONY: modules clean
 
modules:
	make ARCH=$(ARCH) CROSS_COMPILE=$(CROSS_COMPILE) -C $(KERN_DIR) M=$(shell pwd) modules
	cp ./*.ko $(TARGET_DIR)$(MODULE_FINAL_NAME).ko
clean:
	rm -rf *.ko *.o *.mod.c *.mod.o */*.o
	rm -f modules.order
	rm -f Module.symvers
	rm -rf .tmp_versions
	rm -f .*o.cmd */.*.o.cmd
	
#if there are the second_c_file.c need compile together:
#${MODULE_NAME}-y += src/second_c_file.o

obj-m += ${MODULE_NAME}.o
